package com.example.userblog.service;

import com.example.userblog.dao.ArticleDao;
import com.example.userblog.dao.UserDao;
import com.example.userblog.entity.Article;
import com.example.userblog.entity.User;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {
    @Resource
    private ArticleDao articleDao;
    @Autowired
    private UserDao userDao;

    public PageInfo<Article> getAll(Integer page, Integer size){
        PageHelper.startPage(page,size);
        List<Article> list=articleDao.findBySearch();
        return PageInfo.of(list);
    }
    public Article add(Article article){
    articleDao.insertSelective(article);
    return article;

    }
}
